package com.itheima.service.db.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.itheima.domain.db.SoulReport;
import com.itheima.mapper.SoulReportMapper;
import com.itheima.service.db.SoulReportService;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.beans.factory.annotation.Autowired;

@DubboService
public class SoulReportServiceImpl implements SoulReportService {

    @Autowired
    SoulReportMapper soulReportMapper;


    @Override
    public SoulReport findByScore(Integer score) {
        //1.创建条件构造器
        LambdaQueryWrapper<SoulReport>  qw = new LambdaQueryWrapper<>();
        qw.le(SoulReport::getMinScore,score)
                .ge(SoulReport::getMaxScore,score);//分数大于最小值,小于等于最大值
        //2.查询
        SoulReport soulReport = soulReportMapper.selectOne(qw);

        //3.返回结果
        return soulReport;
    }

    @Override
    public SoulReport findById(Integer reportId) {
         return soulReportMapper.selectById(reportId);
    }
}
